<script setup>
import { usePlayerStore, useToolStore } from '@/stores'
import { storeToRefs } from 'pinia'
const toolStore = useToolStore()
const playerStore = usePlayerStore()
const { IsOnReady } = storeToRefs(playerStore)
const { UIShow, LayerTreeShow, AnimationShow, WeatherShow } = storeToRefs(toolStore)

import MqttService from '@/mqtt'
const mqttService = new MqttService()
mqttService.connect()
// mqttService.subscribe('/uavRealDataReq-yt')
// mqttService.subscribe('/uavRealAlarmReq')

const handleToggleUi = () => {
  UIShow.value = true
  __g.settings.setMainUIVisibility(false)
}
</script>
<template>
  <div class="wrap">
    <!-- 模型未加载成功显示动画 -->
    <div class="mask" v-if="!IsOnReady">
      <img src="@img/common/loading.gif" alt="Loading" />
      <div class="text">三维模型加载中……</div>
    </div>
    <!-- 三维视频流 -->
    <RTCPlayer />

    <!-- 头部 -->
    <Header v-if="UIShow" />
    <!-- <transition
      appear
      name="custom-classes-transition"
      enter-active-class="animate__animated animate__fadeInDown"
      leave-active-class="animate__animated animate__fadeOutUp"
    >
      <div class="back" @click="handleToggleUi" v-if="!UIShow">
        <el-tooltip class="box-item" effect="dark" content="返回" placement="bottom">
          <img src="@img/common/back.png" alt="" />
        </el-tooltip>
      </div>
    </transition> -->
    <!-- 菜单 -->
    <transition
      appear
      name="custom-classes-transition"
      enter-active-class="animate__animated animate__fadeInLeft"
      leave-active-class="animate__animated animate__fadeOutLeft"
    >
      <Menu v-if="UIShow && !LayerTreeShow && !AnimationShow && !WeatherShow" />
    </transition>

    <!-- 右边 -->
    <transition
      appear
      name="custom-classes-transition"
      enter-active-class="animate__animated animate__fadeInRight"
      leave-active-class="animate__animated animate__fadeInRight"
    >
      <div class="right">
        <img src="@/assets/tietu/leftpanel.png" />
      </div>
    </transition>

    <!-- 中间上面 -->
    <div class="midtop">
      <img src="@/assets/tietu/midtop-bot.png" />
    </div>

    <!-- 图层树 -->
    <!-- <transition
      name="custom-classes-transition"
      enter-active-class="animate__animated animate__fadeInUp"
      leave-active-class="animate__animated animate__fadeOutDown"
    >
      <LayerTree/>
    </transition> -->

    <!-- 导览列表 -->
    <!-- <transition
      name="custom-classes-transition"
      enter-active-class="animate__animated  animate__fadeInRight"
      leave-active-class="animate__animated  animate__fadeOutRight"
    >
      <Animation v-if="AnimationShow" />
    </transition> -->

    <!-- 天气 -->
    <!-- <transition
      name="custom-classes-transition"
      enter-active-class="animate__animated   animate__fadeInRight"
      leave-active-class="animate__animated  animate__fadeOutRight"
    >
      <Weather v-if="WeatherShow" />
    </transition> -->

    <!-- 添加水印 -->
    <!-- <p class="shuiyin">
      <img src="@img/common/CEPREI.png" alt="" />
    </p> -->

    <!-- 模型加载成功页面路由 -->
    <!-- <router-view
      v-if="IsOnReady && UIShow && !LayerTreeShow && !AnimationShow && !WeatherShow"
    ></router-view> -->
    <router-view v-if="IsOnReady"></router-view>
  </div>
</template>

<style scoped lang="scss">
.wrap {
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: #000;
  // background-color: #8dd1ff;

  .mask {
    position: absolute;
    top: 42%;
    left: 50%;
    transform: translateX(-50%);

    .text {
      text-align: center;
      color: #aaeaff;
      text-align: center;
    }
  }
  .right {
    position: absolute;
    top: 110px;
    right: 0;
    width: 361.5px;
    height: 963px;
    img {
      width: 361.5px;
      height: 963px;
    }
  }
  .midtop {
    position: absolute;
    top: 110px;
    left: 50%;
    margin-left: -373.75px;
    width: 1495px;
    height: 178px;
    img {
      width: 747.5px;
      height: 89px;
    }
  }
  .back {
    position: absolute;
    top: 20px;
    right: 60px;
    width: 40px;
    height: 40px;
    text-align: center;
    line-height: 40px;
    z-index: 9;
    cursor: pointer;

    img {
      width: 100%;
      height: 100%;
    }
  }

  .shuiyin {
    position: fixed;
    z-index: 9;
    bottom: 50px;
    left: 10px;
    width: 80px;
    height: 106px;

    img {
      width: 100%;
      height: 100%;
    }
  }
}
</style>
